<?php
require_once("global.php");

if($act == "searchok")
{
	$thiscate["catename"]=$langs["search".$bi];
	
	$keywords = SafeHtml(rawurldecode($_GET["keywords"]));
	if(!$keywords)
	{
		qgheader();
	}
	$stype = SafeHtml($stype);
	$sysgroup = $PA->rs_sysgroup("0",$stype);
	if(!$sysgroup)
	{
		qgheader();
	}
	$navid = $sysgroup["sign"];
	$id = $PA->sysgroup_cate($sysgroup["id"]);
	
	//网页标题
	$sitetitle = $thiscate["catename"]." - ".$system["sitename".$bi];
	
	//设定每页显示数量
	$psize = 12;
	
	//分页链接
	$pageurl = "search.php?act=searchok&keywords=".rawurlencode($keywords)."&stype=".$stype;
	
	//获取分页ID
	$pageid = intval($pageid);
	if($pageid < 1)
	{
		$pageid = 1;
	}
	$offset = $pageid > 0 ? ($pageid-1)*$psize : 0;
	
	//等于0时获取普通产品,等于1获取新品,等于2时获取新品和普通产品
	$isvouch = 0;
	
	//标题显示字数
	$cut1 = 38;
	
	//内容显示字数
	$cut2 = 110;
	
	//其他条件
	$where = array("like"=>$keywords);
	
	//获取总数
	$msgcount = $PA->msgcount($id,$isvouch,$where);
	
	//当前分类内容
	$msglist = $PA->msglist($id,$cut1,$cut2,$offset,$psize,$isvouch,$where);
	
	//分页
	$pagelist = page($pageurl,$bi,$msgcount,$psize,$pageid);

	FOOT($stype.".list");
}
elseif($act == "searchlink")
{
	$keywords = SafeHtml($_POST["keywords"]);
	if(!$keywords)
	{
		qgheader();
	}
	$stype = SafeHtml($_POST["stype"]);
	$refreshurl = "search.php?act=searchok&keywords=".rawurlencode($keywords)."&stype=".$stype;
	qgheader($refreshurl);
}
else
{
	qgheader();
}
?>